package com.rambo.dsc.controller;

import com.rambo.dsc.util.SpringContextUtil;
import com.rambo.dsd.sys.dao.inter.po.UserPO;
import com.rambo.dsd.sys.ws.inter.UserWs;
import com.rambo.tools.SecurityUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Create by Rambo on 2017/6/21
 **/
@RestController
public class CXFSpringController {
    @RequestMapping("/cxf/spring")
    public Map<String, Object> spring() {
        Map<String, Object> map = new HashMap<>();
        UserWs userWs = (UserWs) SpringContextUtil.getBean("UserWs");
        UserPO user = userWs.getUser("e4f27889972d11e6acede16e8241c0fe");
        map.put("1.获取单个用户:", user);

        user.setPhone("18975468245");
        UserPO userPO1 = userWs.updateUser(user);
        map.put("2.更新单个用户:", userPO1);

        UserPO userPO2 = new UserPO();
        userPO2.setName("rambo");
        userPO2.setPasswd(SecurityUtil.encryptMD5("123456"));
        userPO2.setSex("男");
        userPO2.setYxbz("Y");
        UserPO userPO3 = userWs.addUser(userPO2);
        map.put("3.新增单个用户:", userPO3);

        UserPO userPO4 = new UserPO();
        userPO4.setSex("男");
        List<UserPO> userPOList = userWs.listUser(userPO4);
        map.put("4.获取所有的男用户:", userPOList);

        UserPO userPO5 = new UserPO();
        userPO5.setSex("男");
        List<UserPO> userPOList1 = userWs.listUserOrdrBy(userPO5, "sorts", true);
        map.put("5.获取所有的男用户并按照 sorts 字段排序:", userPOList1);
        return map;
    }
}